﻿Imports YvanSoftware.Orb
Public Class PrebuildDialogs

    Function AskForLogin(ByVal strApiKey As String) As String
        Try
            Dim oFrmLogin As New frmLogin(strApiKey)
            oFrmLogin.ShowDialog()
            If InStr(oFrmLogin.SessionID, "AUTHFAIL") > 0 Then
                Throw New OrbAuthFailureException
            Else
                Return oFrmLogin.SessionID
            End If

        Catch ex As OrbBaseException
            If ex.ShortName = "ERR0001" Then
                Throw ex
            Else
                'handle other exceptions here. These are fatal.
                If ex.ShortName = "ERR0000" Then
                    Throw ex
                Else
                    Fatal(ex.Message & vbCrLf & ex.ExtraInfo)
                End If
            End If
        End Try
    End Function

    Sub Fatal(ByVal message As String)
        Dim oFrm As New dlgFatal(message)
        oFrm.ShowDialog()
    End Sub

End Class
